SEL
Function Name |
SEL |
---|---|
Description |
The SEL function can be used to select one of two enumerated values, depending on a boolean condition (G). The SEL function outputs the same number as one of its inputs. The input that is chosen is dependent on the value of the G input—if G is False, the IN0 value is used as the output; if G is True, the IN1 value is used instead. |
Arguments |
G {BOOL}. The value of the G input is used to determine whether the output matches the IN0 input or the IN1 input. If the G input is False, the output matches IN0; if the G input is True, the output matches IN1. IN0 {ANY} IN1 {ANY} For more information on the data types for the inputs and outputs, see Data Type Hierarchy. |
Returns |
Output {ANY} The output value matches the input value of IN0 or IN1. The value of the G input determines whether IN0 or IN1 is used. |
Example:
Function Block Diagram - SEL:
In this example, the Boolean value for G comes from a tag that references the CurrentValue
property of a 1 bit digital point named 'FlowPresent', (see Add Variables to a Function Block Diagram).
The point variable has been configured as a boolean.
The IN0 and IN1 values are provided by constants. As the 'FlowPresent' value is True (1), the SEL function outputs the same value as IN1, which in this case is 5.
ST Program - SEL:
It is unlikely that you would use a SEL function in an ST program as the same functionality can be provided by an IF statement. However, if you did choose to use a SEL function, you would need to use this syntax:
Output := SEL (G, IN0, IN1);
Where Output, G, IN0 and IN1 are defined as variables earlier in the ST program.
Alternatively, you can use the following syntax:
Output := SEL (G:= True, IN0:= 4, IN1:= 5);
Where the True, 4 and 5 values are the input values (in this case, they are the same values as used in the Function Block Diagram example above).